package net.esj.basic.dao.hibernate;

import java.io.Serializable;
import java.util.List;

import net.esj.basic.dao.Dao;
import net.esj.basic.dao.QueryBuilderDao;
import net.esj.basic.dao.ScalarMapper;
import net.esj.basic.utils.Pagination;

import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;

public interface HibernateDao extends Dao,QueryBuilderDao{

	
	/**
	 * 根据入参精准查找
	 * @param <T>
	 * @param entity
	 * @return
	 */
	public <T> List<T> findList(Object entity);
	
	/**
	 * 根据HQL删除
	 * @param hql
	 */
	public void deleteByHql(String hql);
	
	public <T> T load(Serializable id,Class<T> clazz);
	
	public void flush();

	/**
	 * 获得对象的标准，不建议使用
	 * @param <T>
	 * @param clazz
	 * @return
	 */
	public <T> Criteria getCriteria(Class<T> clazz);
	
	public <T> List<T> findTop(String hql,int count);
	
	public <T> Pagination<T> queryPage(String hql,Pagination<T> page);
	
	public <T> Pagination<T> queryPage(String sql,Pagination<T> page,ScalarMapper mapper);
	
	public List queryList(String hql);
	
	public List queryListBySql(String sql);
	
	public List queryList(String hql,ScalarMapper mapper);
	
	public List queryTop(String hql,int count);
	
	public List queryTop(String hql,int count,ScalarMapper mapper);
	
	public List listByCriteria(DetachedCriteria criteria);
	
	public List topByCriteria(DetachedCriteria criteria,int count);
	
	public Pagination pageByCriteria(DetachedCriteria criteria,Pagination page);
	
	public int countByCriteria(DetachedCriteria criteria);
}
